# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: app-misc/far/far-3.0.3800.ebuild,v 1.4 2014/05/28 08:12:00 itspec.ru Exp $

EAPI="4"

inherit eutils

DESCRIPTION="File and archive manager"
HOMEPAGE="http://farmanager.com/"
SRC_URI="x86_32? ( http://farmanager.com/files/Far30b3800.x86.20140208.7z )
         x86_64? ( http://farmanager.com/files/Far30b3800.x64.20140208.7z )"

LICENSE="FarManager"
RESTRICT="mirror"

SLOT="0"
IUSE="x86_32 x86_64"
REQUIRED_USE="|| ( x86_32 x86_64 )"

KEYWORDS="~x86 ~amd64"

DEPEND="app-arch/p7zip
        media-gfx/icoutils
        media-gfx/imagemagick"

RDEPEND="app-emulation/wine"

S="${WORKDIR}"

src_unpack() {
    cd "${DISTDIR}"
    7z x -o"${S}" ${A} || die "unpack failed"
}

src_install() {
    insinto /opt/${PN}
    doins -r * || die

    for path in $(find /usr/share/icons/hicolor -maxdepth 1 -type d -iname '[0-9]*x[0-9]*'); do
        size=$(basename "${path}")
        convert ${FILESDIR}/Far_17_256x256x32.png -resize "${size}" far.png
        insinto "${path}"/apps
        doins far.png
    done

    exeinto /opt/bin
    doexe "${FILESDIR}/${PN}" || die

    make_desktop_entry far "Far manager" far "System;Filesystem;" || die
}
